<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="../include/tag.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>分销商数据分析</title>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">
    <link rel="stylesheet" href="${ctx}/css/common/table.css">
    <link rel="stylesheet" href="${ctx}/css/ui/distribution/distribution_list.css">
    <%@include file="../include/commonFile.jsp" %>
</head><body>
<!--头部-->
<%@include file="../include/header.jsp" %>
<div class="index-outside">
    <%@include file="../include/sidebar.jsp" %>
    <!--内容-->
    <section>
        <div class="section-main">

            <form class="layui-form" action="${ctx}/distribution/relation/list.do" id="myForm" method="post">
                <input type="hidden" name="pageNo" id="pageNo"/>
                <input type="hidden" name="targetId" id="targetId" value="${targetId}"/>
                <div class="f-search-bar">
                    <div class="search-container">
                        <ul class="search-form-content">
                            <li class="form-item-inline"><label class="search-form-lable"
                                                                style="text-indent: 13px">分销者</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="distributorName" autocomplete="off"
                                           class="layui-input w212" value="${input.distributorName}"
                                           placeholder="请输入查询分销者">
                                </div>
                            </li>
                            <li class="form-item-inline"><label class="search-form-lable">项目名称</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="title" autocomplete="off" class="layui-input"
                                           value="${input.title}" placeholder="请输入查询项目名称">
                                </div>
                            </li>
                            <li class="form-item-inline">
                                <div class="sub-btns">
                                    <div class="sub-btns">
                                        <a class="layui-btn layui-btn-danger"
                                           href="javascript:submitFunction('#myForm')">查询</a>
                                        <a class="layui-btn layui-btn-normal"
                                           href="javascript:resetFunction('#myForm')">重置</a>
                                    </div>
                                </div>
                            </li>
                        </ul>
                        <ul class="search-form-content">
                            <li class="form-item"><label class="search-form-lable">项目类型</label>
                                <div class="check-btn-inner">
                                    <a id="all" href="javascript:void(0);"
                                       onclick="setTimeType($(this),'','#myForm')"${empty input.type ? 'class="active"' : ''}>全部</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),0,'#myForm')" ${input.type == 0 ? 'class="active"' : ''}>玩法</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),2,'#myForm')" ${input.type == 2 ? 'class="active"' : ''}>活动</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),3,'#myForm')" ${input.type == 3 ? 'class="active"' : ''}>文章</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),4,'#myForm')" ${input.type == 4 ? 'class="active"' : ''}>众筹代言</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),6,'#myForm')" ${input.type == 6 ? 'class="active"' : ''}>众筹分销</a>
                                    <input type="hidden" name="type" value="${input.type}"/>
                                </div>
                            </li>
                        </ul>
                        <ul class="search-form-content">
                            <li class="form-item"><label class="search-form-lable">注册时间</label>
                                <div class="check-btn-inner" id="timeType">
                                    <a id="all" href="javascript:void(0);"
                                       onclick="setTimeType($(this),0,'#myForm')" ${empty input.timeType || input.timeType == 0 ? 'class="active"' : ''}>全部</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),1,'#myForm')" ${input.timeType == 1 ? 'class="active"' : ''}>今天</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),2,'#myForm')" ${input.timeType == 2 ? 'class="active"' : ''}>本周内</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),3,'#myForm')" ${input.timeType == 3 ? 'class="active"' : ''}>本月内</a>
                                    <input type="hidden" name="timeType" value="${input.timeType}"/>
                                </div>
                                <div class="layui-inline">
                                    <div class="layui-input-inline">
                                        <input class="layui-input" type="text" name="startDate"
                                               value="${input.startDate}" placeholder="开始日">
                                    </div>
                                    -
                                    <div class="layui-input-inline">
                                        <input class="layui-input" type="text" name="endDate" value="${input.endDate}"
                                               placeholder="截止日">
                                    </div>
                                </div>
                            </li>
                        </ul>
                    </div>

                </div>
            </form>
            <form class="layui-form" action="${ctx}/distribution/relation/targetListExport.do" id="exportForm"
                  method="post">
                <input type="hidden" name="targetId" value="${targetId}"/>
            </form>
            <div class="list-content">
                <%--<ul class="num">
                    <div class="r">
                        <div class="l">
                            <li style="cursor: pointer;" class="r">
                                <c:if test="${empty zipUrl}">
                                    <a class="layui-btn layui-btn-danger layui-btn-sm" id="btnExport">导出EXCEL</a>
                                </c:if>
                                <c:if test="${not empty zipUrl}">
                                    <a class="layui-btn layui-btn-danger layui-btn-sm" id="btnExport">重新生成EXCEL</a>
                                    <a class="layui-btn layui-btn-danger layui-btn-sm" target="_blank" href="${zipUrl}">点击下载</a>
                                </c:if>
                            </li>
                        </div>
                    </div>
                    <p class="cl"></p>
                </ul>--%>
                <div class="cl">
                    <table class="layui-table">
                        <colgroup>
                            <col width="200px">
                            <col>
                            <col width="90px">
                            <col width="200px">
                            <col width="90px">
                            <col width="90px">
                            <col width="90px">
                            <col width="90px">
                        </colgroup>
                        <thead>
                        <tr>
                            <th>分销者</th>
                            <th>项目名称</th>
                            <th>类型</th>
                            <th>上级分销商</th>
                            <th>浏览量</th>
                            <th>分享量</th>
                            <th>报名数</th>
                            <th>下单量</th>
                        </tr>
                        </thead>
                        <tbody>
                        <c:forEach var="distribution" items="${list}">
                            <tr>
                                <td class="table-member"
                                    onclick="openDialogShow('用户名片','${ctx}/system/member/memberView.do?id=${distribution.distributorId}','400px','470px')">
                                    <div class="member-cell">
                                        <div class="member-logo common-img"
                                             >
                                            <img src="<c:if test="${distribution.distributorLogo != null}">${distribution.distributorLogo}?imageMogr2/auto-orient/crop/126x126</c:if>" alt="" onerror="txz.errImg(this)" onload="txz.imgLoad(this)">
                                        </div>
                                        <div class="member-name ellipsis-1"><a class="blue"
                                                                               title="${distribution.distributorName}"
                                                                               href="javascript:void(0);">${distribution.distributorName}</a>
                                        </div>
                                    </div>
                                </td>
                                <td class="ellipsis-1" title="${distribution.title}">
                                        ${distribution.title}
                                </td>
                                <td>
                                    <c:if test="${distribution.type == 0 || distribution.type == 1}">
                                        玩法
                                    </c:if>
                                    <c:if test="${distribution.type == 2}">
                                        活动
                                    </c:if>
                                    <c:if test="${distribution.type == 3}">
                                        文章
                                    </c:if>
                                    <c:if test="${distribution.type == 4}">
                                        众筹代言
                                    </c:if>
                                    <c:if test="${distribution.type == 6}">
                                        众筹分销
                                    </c:if>
                                </td>
                                <td>
                                        ${distribution.parentName}
                                </td>

                                <td>
                                        ${distribution.viewNum}
                                </td>
                                <td>
                                        ${distribution.shareNum}
                                </td>
                                <td>
                                    <a class="blue applyNum count-num" data-id="${distribution.id}"
                                       data-targetId="${distribution.targetId}">${distribution.applyNum}</a>
                                </td>
                                <td>
                                    <a class="blue salesNum count-num"
                                       data-id="${distribution.id}"> ${distribution.salesNum}</a>
                                </td>

                            </tr>
                        </c:forEach>
                        </tbody>
                    </table>
                </div>
            </div>
            <div id="page_content" class="page-container"></div>
        </div><!--底部-->
        <%@include file="../include/footer.jsp" %>
    </section>
</div>



<script type="text/javascript" src="${ctx}/script/common/list.js"></script>
<script type="text/javascript">

    <%--showActive('${input.startDate}', '${input.endDate}', '#timeType');--%>


    $(function () {
        //加载分页
        loadPageNew({elem: 'page_content', totalCount: '${page.totalCount}', limit: '${page.limit}', page: '${page.page}'});
        layui.use(['laydate'], function () {
            var laydate = layui.laydate;
            // 查询发布日期
            var start = {
                elem: 'input[name=startDate]'
            };

            var end = {
                elem: 'input[name=endDate]'
            };
            laydate.render(start);
            laydate.render(end);
        });
        var url = location.href;
        $('#myForm').attr('action', url)
        $('.salesNum').click(function () {
            var id = this.dataset.id;
            window.location.href = '${ctx}/order/order/distributorList.do?distributionId=' + id;
        });

        $('.applyNum').click(function () {
            var id = this.dataset.id;
            var targetId = $(this).attr("data-targetId");
            window.location.href = '${ctx}/activity/memberAct/memberActList.do?distributionId=' + id + "&actId=" + targetId;
        });

        $("#btnExport").click(function () {
            layer.confirm('确认要导出Excel吗?', {
                icon: 3,
                title: '系统提示'
            }, function (index) {
                //loading层
                var loadIndex = layer.load(1, {
                    shade: [0.1,'#fff'] //0.1透明度的白色背景
                });
                $.post("${ctx}/distribution/relation/targetListExport.do", $("#myForm").serialize(), function (data) {
                    layer.close(loadIndex);
                    if (data.success == true) {
                        util.layerAlertSuccess("导出成功，请点击下载按钮即可下载文件。", function () {
                            window.location.reload();
                        })
                    } else {
                        util.layerAlertError("操作失败")
                    }
                });
                top.layer.close(index);
            });
        });
    });
</script>
<script type="text/javascript">
    txz.initHeader({
        nav:[{
            name: '分销商数据分析',
            curr: true
        }],
        info:'<span class="f12">共<b id="totalCount">${page.totalCount}</b>条记录</span>'
    });
</script>
</body>
</html>